/*
 * SimpleContextMerger.java
 *
 * Created on 16 de septiembre de 2004, 12:03
 */

package ocp.context;

import java.util.Enumeration;

/**
 * This class is the simplest of all context mergers. It merges
 * the contextual information by adding it, and does no interpretation of
 * the information.
 * @author Ignacio Nieto Carvajal.
 */
public class SimpleContextMerger implements ContextMerger, java.io.Serializable {
    
    public SimpleContextMerger() {}
    
    public ContextualInformationList mergeContexts(java.util.Vector contexts)
    {
        ContextualInformationList result = new ContextualInformationList();

        try {
            for (Enumeration e = contexts.elements(); e.hasMoreElements();) {
                Context c = (Context) e.nextElement();
                ContextualInformationList l = c.getContextualInformation();
                for (Enumeration e2 = l.getContextualInformation(); e2.hasMoreElements();)
                    result.addContextualInformation((ContextualInformation ) e2.nextElement());
            }
        } catch (ocp.context.ContextualInformationAbsentException ciae) {
            System.err.println("Contextual information absent.");
        }
        
        return result;
    }
    
}
